package com.gome.han.cloud.hystrix;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;

/**
* @author hanpeng
* @version 创建时间：2020年8月8日 下午12:57:45
* @ClassName 类名称
* @Description 类描述
*/
@SpringBootApplication  //这是个springboot项目
@EnableEurekaClient    //这个是个eureka 客户端
@EnableCircuitBreaker  //开启hystrix 熔断支持
public class Application {
	public static void main(String[] args) {
		SpringApplication.run(Application.class);
	}
	
	@Bean
	public ServletRegistrationBean<HystrixMetricsStreamServlet> getServletRegister() {
		ServletRegistrationBean<HystrixMetricsStreamServlet> servletRegistrationBean = new ServletRegistrationBean<HystrixMetricsStreamServlet>(new HystrixMetricsStreamServlet());
		servletRegistrationBean.addUrlMappings("/actuator/hystrix.stream");
		//页面上有提示
		return servletRegistrationBean;
		
	}
}
